 #@layout()
 #define content()

<span class="layui-breadcrumb">
  <a href="/">首页</a>
  <a href="/admin/website"><cite>站点管理</cite></a>
</span>

<hr>


<div class="layui-field-box">
<form class="layui-form" action="/admin/user">
    <div class="layui-form-item">
    		<div class="layui-inline">
	      <label class="layui-form-label">搜索内容</label>
	      <div class="layui-input-inline">
	        <input type="text" name="searchContent" autocomplete="off" class="layui-input" placeholder="请输入内容搜索">
	      </div>
	    </div>
	    
	    <div class="layui-inline">
	      <label class="layui-form-label">状态</label>
	      <div class="layui-input-inline">
	      		#set(SELECT_MAP={})
	      		#set(SELECT_MAP["dicTypeCode"]="WEBSITE_STATUS")
	      		#set(SELECT_MAP["name"]="status")
	      	   	#set(SELECT_MAP["id"]="status")
	        	   	#@dic_get_select(SELECT_MAP)
	      </div>
	    </div>
	    
	    <button class="layui-btn" type="button" id="btnSearch">搜索</button>
	    <button class="layui-btn layui-btn-normal" type="reset" >重置</button>
	    <a class="layui-btn layui-btn-danger" href="/admin/website/add" >新增</a>
	    
	</div>
</form>	    
</div>

<table class="layui-hide" id="dataTable"></table>

<script type="text/html" id="actionTpl">
  	<a href="javascript:doStartUsing('{{d.id}}');" class="layui-table-link" >启用</a>
  	<a href="javascript:doForbidden('{{d.id}}');" class="layui-table-link" >禁用</a>
</script>

#end

#define js()

<script>

layui.use('table', function() {
	
	var table = layui.table;
	table.render({
		elem : '#dataTable',
		url : '/admin/website/pagequery',
		cols : [ [
	      {field:'name', title: '站点名称'},
	      {field:'nickname', title: '联系人'},
	      {field:'email', title: '邮箱'},
	      {field:'cellphone', title: '手机'},
	      {field:'sld', title: '二级域名'},
	      {field:'createTime', title: '创建时间', sort: true},
	      {field:'status_dic', title: '状态'},
	      {templet:"#actionTpl",width:'150',title: '操作'}
		] ],
		page : true
	});
	
	$("#btnSearch").click(function(){
		
		var searchContent=$(":input[name='searchContent']").val();
		var status=$(":input[name='status']").val();
		
		//执行重载
		table.reload('dataTable', {
			page : {
				curr : 1//重新从第 1 页开始
			},
			where : {
				searchContent:searchContent,
				status:status
			}
		});
		
	});

});

function doDetail(id){
	window.location.href="/admin/website/view?id="+id;
}

function doStartUsing(id){
	layui.layer.confirm('确认启用么?', function(index){
		$.ajax({
			type:'get',
			url:'/admin/website/startUsing',
			data:'id='+id,
			success:function(data){
				layui.table.reload('dataTable');
			}
		});
		layui.layer.close(index);
	}); 
}

function doForbidden(id){
	layui.layer.confirm('确认禁用么?', function(index){
		$.ajax({
			type:'get',
			url:'/admin/website/forbidden',
			data:'id='+id,
			success:function(data){
				layui.table.reload('dataTable');
			}
		});
		layui.layer.close(index);
	}); 
}

</script>

#end


